home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / tnos / tnos100s / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-15  |  31.9 KB  |  1,313 lines

  1. /* A collection of stuff heavily dependent on the configuration info
  2.  * in config.h. The idea is that configuration-dependent tables should
  3.  * be located here to avoid having to pepper lots of .c files with #ifdefs,
  4.  * requiring them to include config.h and be recompiled each time config.h
  5.  * is modified.
  6.  *
  7.  * Copyright 1991 Phil Karn, KA9Q
  8.  */
  9.  /* Mods by PA0GRI */
  10.  
  11. #include <stdio.h>
  12. #include <dos.h>
  13. #include <conio.h>
  14. #include "global.h"
  15. #include "config.h"
  16. #include "mbuf.h"
  17. #include "timer.h"
  18. #include "proc.h"
  19. #include "iface.h"
  20. #include "ip.h"
  21. #include "tcp.h"
  22. #include "udp.h"
  23. #ifdef    ARCNET
  24. #include "arcnet.h"
  25. #endif
  26. #include "lapb.h"
  27. #include "ax25.h"
  28. #include "enet.h"
  29. #include "kiss.h"
  30. #include "netrom.h"
  31. #include "nr4.h"
  32. #include "pktdrvr.h"
  33. #include "ppp.h"
  34. #include "slip.h"
  35. #include "arp.h"
  36. #include "icmp.h"
  37. #include "hardware.h"    /***/
  38. #include "usock.h"
  39. #include "cmdparse.h"
  40. #include "commands.h"
  41. #include "mailbox.h"
  42. #include "mailcli.h"
  43. #include "ax25mail.h"
  44. #include "nr4mail.h"
  45. #include "tipmail.h"
  46. #include "bootp.h"
  47. #include "daemon.h"
  48. #include "slhc.h"
  49. #include "rspf.h"
  50. #include "main.h"
  51. #include "gps.h"
  52.  
  53. static int dostart __ARGS((int argc,char *argv[],void *p));
  54. static int dostop __ARGS((int argc,char *argv[],void *p));
  55. #ifdef WPAGES
  56. extern int dooldwpages __ARGS((int argc,char *argv[],void *p));
  57. #endif
  58. extern int dossaver __ARGS((int argc,char *argv[],void *p));
  59. extern int dodrive __ARGS((int argc,char *argv[],void *p));
  60. #ifdef XSPAWN
  61. extern int doxspawn __ARGS((int argc,char *argv[],void *p));
  62. #endif
  63. #ifdef ITT
  64. extern int donv __ARGS((int argc,char *argv[],void *p));
  65. #endif
  66. extern int doquote __ARGS((int argc,char *argv[],void *p));
  67. #ifdef MBFWD
  68. extern int doforward __ARGS((int argc,char *argv[],void *p));
  69. #endif
  70. #ifdef RDATE
  71. extern int dordate __ARGS((int argc,char *argv[],void *p));
  72. #endif
  73. #ifdef RLOGINSERV
  74. int rlogin0 __ARGS((int argc,char *argv[],void *p));
  75. int rlogin1 __ARGS((int argc,char *argv[],void *p));
  76. #endif
  77. extern int doerror __ARGS((int argc,char *argv[],void *p));
  78. #ifdef TUTOR
  79. extern int doscript __ARGS((int argc,char *argv[],void *p));
  80. extern int dotutor __ARGS((int argc,char *argv[],void *p));
  81. int tutor0 __ARGS((int argc,char *argv[],void *p));
  82. int tutor1 __ARGS((int argc,char *argv[],void *p));
  83. extern int doinfo __ARGS((int argc,char *argv[],void *p));
  84. int info0 __ARGS((int argc,char *argv[],void *p));
  85. int info1 __ARGS((int argc,char *argv[],void *p));
  86. extern int donews __ARGS((int argc,char *argv[],void *p));
  87. int news0 __ARGS((int argc,char *argv[],void *p));
  88. int news1 __ARGS((int argc,char *argv[],void *p));
  89. #endif
  90. #ifdef TNOS_68K
  91. extern void screendaemon __ARGS((int i, char *v1, void *v2));
  92. #endif
  93.  
  94. extern int docolor __ARGS((int argc,char *argv[],void *p));
  95. extern int dostatline __ARGS((int argc,char *argv[],void *p));
  96. extern int doprompt __ARGS((int argc,char *argv[],void *p));
  97. extern int doview __ARGS((int argc,char *argv[],void *p));
  98. extern int dosystime __ARGS((int argc,char *argv[],void *p));
  99. extern int dorepeat __ARGS((int argc,char *argv[],void *p));
  100.  
  101. #ifdef    NNTPS
  102. extern int donntpcli __ARGS((int argc,char *argv[],void *p));
  103. extern int nntp0 __ARGS((int argc,char *argv[],void *p));
  104. extern int nntp1 __ARGS((int argc,char *argv[],void *p));
  105. #endif
  106.  
  107. #ifdef    CONVERS
  108. int conv0 __ARGS((int argc,char *argv[],void *p));
  109. int conv1 __ARGS((int argc,char *argv[],void *p));
  110. int doconvers __ARGS((int argc,char *argv[],void *p));
  111. int doconf __ARGS((int argc,char *argv[],void *p));
  112.  
  113. #endif
  114.  
  115. #ifdef  AX25
  116. static void axip __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  117.     char *dest,struct mbuf *bp,int mcast));
  118. static void axarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  119.     char *dest,struct mbuf *bp,int mcast));
  120. static void axrarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  121.     char *dest,struct mbuf *bp,int mcast));
  122. static void axnr __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  123.     char *dest,struct mbuf *bp,int mcast));
  124. #endif
  125.  
  126. struct mbuf *Hopper;
  127. unsigned Nsessions = NSESSIONS;
  128.  
  129. /* Free memory threshold, below which things start to happen to conserve
  130.  * memory, like garbage collection, source quenching and refusing connects
  131.  */
  132. int32 Memthresh = MTHRESH;
  133.  
  134. #ifndef TNOS_68K
  135. int Nibufs = NIBUFS;        /* Number of interrupt buffers */
  136. unsigned Ibufsize = IBUFSIZE;    /* Size of each interrupt buffer */
  137. #endif
  138.  
  139. /* Transport protocols atop IP */
  140. struct iplink Iplink[] = {
  141.     TCP_PTCL,    tcp_input,
  142.     UDP_PTCL,    udp_input,
  143.     ICMP_PTCL,    icmp_input,
  144. #ifdef ENCAP
  145.     IP_PTCL,    ipip_recv,
  146. #endif
  147. #ifdef  AXIP
  148.     AX25_PTCL,    axip_input,
  149. #endif
  150. #ifdef    RSPF
  151.     RSPF_PTCL,    rspf_input,
  152. #endif    /* RSPF */
  153.     0,        0
  154. };
  155.  
  156. /* Transport protocols atop ICMP */
  157. struct icmplink Icmplink[] = {
  158.     TCP_PTCL,    tcp_icmp,
  159.     0,        0
  160. };
  161.  
  162. /* ARP protocol linkages */
  163. struct arp_type Arp_type[NHWTYPES] = {
  164. #ifdef    NETROM
  165.     AXALEN, 0, 0, 0, 0, NULLCHAR, pax25, setcall,    /* ARP_NETROM */
  166. #else
  167.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  168. #endif
  169.  
  170. #ifdef    ETHER
  171.     EADDR_LEN,IP_TYPE,ARP_TYPE,REVARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  172. #else
  173.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  174. #endif
  175.  
  176.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,        /* ARP_EETHER */
  177.  
  178. #ifdef    AX25
  179.     AXALEN, PID_IP, PID_ARP, PID_RARP, 10, Ax25multi[0], pax25, setcall,
  180. #else
  181.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,        /* ARP_AX25 */
  182. #endif
  183.  
  184.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,        /* ARP_PRONET */
  185.  
  186.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,        /* ARP_CHAOS */
  187.  
  188.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,        /* ARP_IEEE802 */
  189.  
  190. #ifdef    ARCNET
  191.     AADDR_LEN, ARC_IP, ARC_ARP, 0, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  192. #else
  193.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  194. #endif
  195.  
  196.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,        /* ARP_APPLETALK */
  197. };
  198.  
  199. #ifdef    AX25
  200. /* Linkage to network protocols atop ax25 */
  201. struct axlink Axlink[] = {
  202.     PID_IP,        axip,
  203.     PID_ARP,    axarp,
  204. #ifdef RARP
  205.     PID_RARP,   axrarp,
  206. #endif
  207. #ifdef  NETROM
  208.     PID_NETROM,    axnr,
  209. #endif
  210.     PID_NO_L3,    axnl3,
  211.     0,        NULL,
  212. };
  213. #endif
  214.  
  215. #ifdef  MAILCLIENT
  216. struct daemon Mailreaders[] = {
  217. #ifdef    POP2CLIENT
  218.     "POP2",         2048,   pop2_job,
  219. #endif
  220. #ifdef  POP3CLIENT
  221.     "POP3",         2048,   pop3_job,
  222. #endif
  223.     NULLCHAR
  224. };
  225. #endif
  226.  
  227. #ifndef BOOTP
  228. int WantBootp = 0;
  229.  
  230. bootp_validPacket(ip,bpp)
  231. struct ip *ip;
  232. struct mbuf **bpp;
  233. {
  234.     return 0;
  235. }
  236. #endif
  237.  
  238. #ifdef    MAILBOX
  239. void (*Listusers) __ARGS((int s)) = listusers;
  240. #else
  241. void (*Listusers) __ARGS((int s)) = NULL;
  242. #endif
  243.  
  244. /* daemons to be run at startup time */
  245. struct daemon Daemons[] = {
  246.     "killer",    1024,    killer,
  247.     "timer",    1024,    timerproc,
  248.     "network",    3072,    network,
  249.     "keyboard",    512,    keyboard,
  250. #ifndef TNOS_68K
  251.     "gcollect",    512,    gcollect,
  252. #else
  253.     "screendaemon", 512,    screendaemon,
  254. #endif
  255.     NULLCHAR,    0,    NULLVFP
  256. };
  257.  
  258. struct iftype Iftypes[] = {
  259.     /* This entry must be first, since Loopback refers to it */
  260.     "None",        NULL,        NULL,        NULL,
  261.     NULL,        CL_NONE,    0,
  262.  
  263. #ifdef    AX25
  264.     "AX25",        ax_send,    ax_output,    pax25,
  265.     setcall,    CL_AX25,    AXALEN,
  266. #endif
  267.  
  268. #ifdef    SLIP
  269.     "SLIP",        slip_send,    NULL,        NULL,
  270.     NULL,        CL_NONE,    0,
  271. #endif
  272.  
  273. #ifdef    ETHER
  274.     /* Note: NULL is specified for the scan function even though
  275.      * gether() exists because the packet drivers don't support
  276.      * address setting.
  277.      */
  278.     "Ethernet",    enet_send,    enet_output,    pether,
  279.     NULL,        CL_ETHERNET,    EADDR_LEN,
  280. #endif
  281.  
  282. #ifdef    NETROM
  283.     "NETROM",    nr_send,    NULL,        pax25,
  284.     setcall,    CL_NETROM,    AXALEN,
  285. #endif
  286.  
  287. #ifdef    SLFP
  288.     "SLFP",        pk_send,    NULL,        NULL,
  289.     NULL,        CL_NONE,    0,
  290. #endif
  291.  
  292. #ifdef    PPP
  293.     "PPP",        ppp_send,    ppp_output,    NULL,
  294.     NULL,        CL_PPP,    0,
  295. #endif
  296.  
  297.     NULLCHAR
  298. };
  299.  
  300. extern int dowrite(),dowriteall(),dotest(),docopy(),dohistory();
  301.  
  302. /* Command lookup and branch tables */
  303. struct cmds DFAR Cmds[] = {
  304.     /* The "go" command must be first */
  305.     "",        go,        0, 0, NULLCHAR,
  306.     "?",        dohelp,        0, 0, NULLCHAR,
  307. #ifndef    AMIGA
  308. #ifdef SHELL
  309.     "!",        doshell,    0, 0, NULLCHAR,
  310. #endif
  311. #endif
  312. #ifdef ALLSESSIONS
  313.     "abort",    doabort,    0, 0, NULLCHAR,
  314. #endif
  315. #ifdef  AMIGA
  316.     "amiga",    doamiga,    0, 0, NULLCHAR,
  317. #endif
  318. #if    (defined(MAC) && defined(APPLETALK))
  319.     "applestat",    doatstat,    0,    0, NULLCHAR,
  320. #endif
  321. #if    (defined(AX25) || defined(ETHER) || defined(APPLETALK))
  322.     "arp",        doarp,        0, 0, NULLCHAR,
  323. #endif
  324. #ifdef ASY
  325.     "asystat",    doasystat,    0, 0, NULLCHAR,
  326. #endif
  327. #ifdef ATCMD
  328.     "at",       doat,       0, 0, NULLCHAR,
  329. #endif
  330.     "attach",    doattach,    0, 2,
  331.         "attach <hardware> <hw specific options>",
  332.     "attended",    doattended,    0, 0, NULLCHAR,
  333. #ifdef    AX25
  334. #ifdef AUTOROUTE
  335.     "autoroute",doax25autoroute, 0, 0, NULLCHAR,
  336. #endif /* AUTOROUTE */
  337.     "ax25",     doax25,     0, 0, NULLCHAR,
  338. #endif /* AX25 */
  339. #ifdef    MAILBOX
  340.     "bbs",      dobbs,      2048, 0, NULLCHAR,
  341. #endif
  342. #ifdef EXPIRY
  343.     "bid",   dooldbids,  0, 0, NULLCHAR,
  344. #endif
  345. #ifdef    BOOTP
  346.     "bootp",    dobootp,    0, 0, NULLCHAR,
  347.     "bootpd",    bootpdcmd,     0, 0, NULLCHAR,
  348. #endif
  349. #ifdef RLINE
  350.     "bulletin", dombrline,  0, 0, NULLCHAR,
  351. #endif
  352. /* This one is out of alpabetical order to allow abbreviation to "c" */
  353. #ifdef    AX25
  354. #ifdef ALLSESSIONS
  355.     "connect",  doconnect,  1024, 3,
  356.     "connect <interface> <callsign>",
  357. #endif
  358. #endif
  359. #ifdef CALLBOOK
  360.     "callserver", doinetcallserver, 0, 0, NULLCHAR,
  361. #endif
  362. #if defined(CALLCLI) || defined(SAMCALLB)
  363.   "callbook", docallbook, 1024, 2, "callbook CALLSIGN",
  364. #endif
  365. #if defined(CALLCLI) || defined(SAMCALLB)
  366.   "callserver", docallserver, 0, 0, NULLCHAR,
  367. #endif
  368. #if !defined(UNIX) && !defined(AMIGA)
  369. #ifdef ALLCMD
  370.     "cd",       docd,       0, 0, NULLCHAR,
  371. #endif
  372. #ifdef CALLSERVER
  373.   "cdrom", docdrom, 0, 0, NULLCHAR,
  374. #endif
  375. #endif
  376. #if defined(ALLCMD) && defined(TNOS_68K)
  377.     "chd",       docd,       0, 0, NULLCHAR,
  378. #endif
  379.     "close",    doclose,    0, 0, NULLCHAR,
  380.     "cls",      clrscr,      0, 0, NULLCHAR,
  381.     "color",    docolor,    0, 3,"color <background> <foreground>",
  382.     "comm",        doasycomm,    0, 3,"comm <interface> <text-string>",
  383. #if defined(ALLSESSIONS) && defined(CONVERS)
  384.     "conference",    doconf,        1024, 0, NULLCHAR,
  385.     "convers",    doconvers,    0, 0, NULLCHAR,
  386. #endif
  387. #ifdef ALLCMD
  388.     "copy",     docopy,     0, 3,"copy <file> <newfile>",
  389. #endif
  390. /* This one is out of alpabetical order to allow abbreviation to "d" */
  391. #ifdef ALLSESSIONS
  392.     "disconnect",   doclose,    0, 0, NULLCHAR,
  393. #endif
  394. #if defined(ALLCMD) && defined(TNOS_68K)
  395.     "deldir",    dormd,      0, 2, "deldir <directory>",
  396. #endif
  397. #ifdef ALLCMD
  398.     "delete",   dodelete,   0, 2, "delete <file>",
  399. #endif
  400.     "detach",   dodetach,   0, 2, "detach <interface>",
  401. #ifdef    DIALER
  402.     "dialer",    dodialer,    512, 2,
  403.     "dialer <iface> [<file> [<seconds> [<pings> [<hostid>]]]]",
  404. #endif
  405. #ifndef AMIGA
  406. #ifdef ALLCMD
  407.     "dir",      dodir,      0, 0, NULLCHAR,
  408. #endif
  409. #endif
  410.     "domain",    dodomain,    0, 0, NULLCHAR,
  411. #ifdef    DRSI
  412.     "drsistat",    dodrstat,    0, 0, NULLCHAR,
  413. #endif
  414. #ifdef ALLCMD
  415.     "dump",     domdump,    0, 0, NULLCHAR,
  416. #endif
  417. #ifdef    EAGLE
  418.     "eaglestat",    doegstat,    0, 0, NULLCHAR,
  419. #endif
  420.     "echo",        doecho,        0, 0, NULLCHAR,
  421.     "eol",        doeol,        0, 0, NULLCHAR,
  422.     "errors",   doerror,    0, 0, NULLCHAR,
  423. #if    (!defined(MSDOS) || defined(ESCAPE))
  424.     "escape",    doescape,    0, 0, NULLCHAR,
  425. #endif
  426. #ifdef    PC_EC
  427.     "etherstat",    doetherstat,    0, 0, NULLCHAR,
  428. #endif
  429.     "exit",        doexit,        0, 0, NULLCHAR,
  430. #ifdef EXPIRY
  431.     "expire",   doexpire,   0, 0, NULLCHAR,
  432. #endif
  433. #ifdef ALLCMD
  434.     "finger",   dofinger,   1024, 2, "finger name@host",
  435.     "fkey",        dofkey,        0, 0, NULLCHAR,
  436. #ifdef MBFWD
  437.     "forward",    doforward,    0, 0, NULLCHAR,
  438. #endif
  439. #endif
  440. #ifdef ALLSESSIONS
  441.     "ftp",      doftp,      2048, 2, "ftp <address>",
  442.     "ftype",    doftype,    0, 0, NULLCHAR,
  443. #endif
  444. #ifdef FTPTDISC
  445.     "ftptdisc", doftptdisc, 0, 0, NULLCHAR,
  446. #endif
  447. #ifdef GPS
  448.     "gps",        dogps,        0, 0, NULLCHAR,
  449. #endif
  450. #ifdef HAPN
  451.     "hapnstat",    dohapnstat,    0, 0, NULLCHAR,
  452. #endif
  453.     "help",        dohelp,        0, 0, NULLCHAR,
  454.     "history",    dohistory,    0, 0, NULLCHAR,
  455. #ifdef    HOPCHECK
  456.     "hop",        dohop,        0, 0, NULLCHAR,
  457. #endif
  458.     "hostname",    dohostname,    0, 0, NULLCHAR,
  459. #ifdef    HS
  460.     "hs",        dohs,        0, 0, NULLCHAR,
  461. #endif
  462.     "icmp",        doicmp,        0, 0, NULLCHAR,
  463.     "ifconfig",    doifconfig,    0, 0, NULLCHAR,
  464. #ifdef TUTOR
  465.     "info",     doinfo,     512, 0, NULLCHAR,
  466. #endif
  467.     "ip",       doip,       0, 0, NULLCHAR,
  468. #ifdef    MSDOS
  469.     "isat",        doisat,        0, 0, NULLCHAR,
  470. #endif    
  471.     "kick",        dokick,        0, 0, NULLCHAR,
  472. #ifdef LOCK
  473.     "lock",     dolock,     0, 0, NULLCHAR,
  474. #endif
  475.     "log",      dolog,      0, 0, NULLCHAR,
  476. #ifdef LZW
  477.     "lzw",      dolzw,      0, 2, "lzw <mode|bits>",
  478. #endif
  479. #if defined(ALLCMD) && !defined(ITT)
  480.     "mail",     dobmail,    0, 0, NULLCHAR,
  481. #endif
  482. #if defined(ALLCMD) && defined(TNOS_68K)
  483.     "makdir",    domkd,      0, 2, "makdir <directory>",
  484. #endif
  485. #ifdef  MAILBOX
  486.     "mbox",        dombox,        0, 0, NULLCHAR,
  487. #endif
  488. #ifdef ALLCMD
  489.     "md",    domkd,      0, 2, "md <directory>",
  490. #endif
  491. #if !defined(UNIX) && !defined(TNOS_68K)
  492.     "memory",    domem,        0, 0, NULLCHAR,
  493. #endif
  494. #ifdef ALLCMD
  495.     "mkdir",    domkd,      0, 2, "mkdir <directory>",
  496. #endif
  497. #ifdef  AX25
  498.     "mode",        domode,        0, 2, "mode <interface>",
  499. #endif
  500. #ifdef ALLCMD
  501.     "more",     domore,     0, 2, "more <filename> [searchstring]",
  502.     "motd",        domotd,        0, 0, NULLCHAR,
  503. #endif
  504. #ifdef  MSDOS
  505. #ifdef MULTITASK
  506.     "multitask",    dobackg,    0, 0, NULLCHAR,
  507. #endif
  508. #endif
  509. #ifdef    NETROM
  510.     "netrom",    donetrom,    0, 0, NULLCHAR,
  511. #endif    /* NETROM */
  512. #ifdef TUTOR
  513.     "news",     donews,     512, 0, NULLCHAR,
  514. #endif
  515. #if (defined(NNTP) || defined(NNTPS))
  516.     "nntp",        donntp,        0, 0, NULLCHAR,
  517. #endif
  518. #ifdef NRS
  519.     "nrstat",    donrstat,    0, 0, NULLCHAR,
  520. #endif
  521. #ifdef ITT
  522.     "nvram",    donv,        0, 0, NULLCHAR,
  523. #endif
  524.     "param",    doparam,    0, 2, "param <interface>",
  525.     "ping",        doping,        0, 2,
  526.     "ping <hostid> [<length> [<interval> [incflag]]]",
  527. #ifdef    PI
  528.     "pistatus",    dopistat,    0, 0, NULLCHAR,
  529. #endif
  530. #ifdef    POP
  531.     "pop",        dopop,        0, 0, NULLCHAR,
  532. #endif
  533. #ifdef  MAILCLIENT
  534.     "popmail",    domsread,    0, 0, NULLCHAR,
  535. #endif
  536. #ifdef GPS
  537.     "position",    doposition,    0, 0, NULLCHAR,
  538. #endif
  539. #ifdef PPP
  540.     "ppp",        doppp_commands,    0, 0, NULLCHAR,
  541. #endif
  542.     "prompt",    doprompt,    0, 0, NULLCHAR,
  543.     "ps",        ps,        0, 0, NULLCHAR,
  544. #if    !defined(UNIX) && !defined(AMIGA)
  545. #ifdef ALLCMD
  546.     "pwd",      docd,       0, 0, NULLCHAR,
  547. #endif
  548. #endif
  549.     "quote",    doquote,    1024, 0, NULLCHAR,
  550. #if    (defined(AX25) || defined(ETHER))
  551. #ifdef RARP
  552.     "rarp",     dorarp,     0, 0, NULLCHAR,
  553. #endif /* RARP */
  554. #endif
  555. #ifdef ALLCMD
  556.     "rd",    dormd,      0, 2, "rd <directory>",
  557. #endif
  558. #ifdef  RDATE
  559.     "rdate",    dordate,    0, 0, NULLCHAR,
  560. #endif
  561. #ifdef ALLCMD
  562.     "record",   dorecord,   0, 0, NULLCHAR,
  563. #endif
  564.     "remote",   doremote,   0, 3, "remote [-p port] [-k key] [-a kickaddr] <address> exit|reset|kick",
  565. #ifdef ALLCMD
  566.     "rename",   dorename,   0, 3, "rename <oldfile> <newfile>",
  567. #endif
  568.     "repeat",   dorepeat, 512, 3, "repeat <interval> <command> [args...]",
  569.     "reset",    doreset,    0, 0, NULLCHAR,
  570. #ifdef    RIP
  571.     "rip",        dorip,        0, 0, NULLCHAR,
  572. #endif
  573. #if defined(RLOGINCLI) || defined(RLOGINSERV)
  574.     "rlogin",    dorlogin,    2048, 2, "rlogin <address>",
  575. #endif
  576. #ifdef ALLCMD
  577.     "rmdir",    dormd,      0, 2, "rmdir <directory>",
  578. #endif
  579.     "route",    doroute,    0, 0, NULLCHAR,
  580. #ifdef    RSPF
  581.     "rspf",        dorspf,        0, 0, NULLCHAR,
  582. #endif    /* RSPF */
  583.     "session",    dosession,    0, 0, NULLCHAR,
  584. #ifdef    SCC
  585.     "sccstat",    dosccstat,    0, 0, NULLCHAR,
  586. #endif
  587. #ifdef TUTOR
  588.     "script",    doscript,    0, 2, "script <filename>",
  589. #endif
  590. #if    !defined(AMIGA)
  591. #ifdef SHELL
  592.     "shell",    doshell,    0, 0, NULLCHAR,
  593. #endif
  594. #endif
  595.     "skick",    dokicksocket,0,2, "skick <socket#>",
  596.     "smtp",     dosmtp,     0, 0, NULLCHAR,
  597.     "socket",    dosock,        0, 0, NULLCHAR,
  598.     "source",    dosource,    0, 2, "source <filename>",
  599. #ifdef  AX25
  600. #ifdef ALLSESSIONS
  601. #ifdef ALLSERV
  602.     "split",  doconnect,  1024, 3,    "split <interface> <callsign>",
  603. #endif
  604. #endif
  605. #endif
  606. #ifdef SCREENSAVER
  607.     "ssaver",    dossaver,    0, 0, NULLCHAR,
  608. #endif
  609. #ifdef    SERVERS
  610.     "start",    dostart,    0, 2, "start <servername>",
  611. #endif
  612.     "statline",    dostatline, 0, 0, NULLCHAR,
  613.     "status",   dostatus,   0, 0, NULLCHAR,
  614. #ifdef    SERVERS
  615.     "stop",        dostop,        0, 2, "stop <servername>",
  616. #endif
  617. #ifdef  TRACE
  618.     "strace",   dostrace,   0, 0, NULLCHAR,
  619. #endif
  620. #ifdef ALLCMD
  621.     "tail",     dotail,     0, 2, "tail <filename> [lines]",
  622. #endif
  623.     "tcp",      dotcp,      0, 0, NULLCHAR,
  624. #ifdef ALLSESSIONS
  625.     "telnet",   dotelnet,   1024, 2, "telnet <address> [port]",
  626. #endif
  627. #ifdef nope
  628.     "test",     dotest,     0, 0, NULLCHAR,
  629. #endif
  630. #ifdef  MAILBOX
  631.     "thirdparty",    dothirdparty,    0, 0, NULLCHAR,
  632. #endif
  633.     "time",     dosystime,  0, 0, NULLCHAR,
  634.     "tip",      dotip,      256, 2, "tip <iface (asyc only!)>",
  635. #ifdef  TRACE
  636.     "trace",    dotrace,    0, 0, NULLCHAR,
  637. #endif
  638. #ifdef ALLSERV
  639.     "ttylink",  dotelnet,  1024, 2, "ttylink <address> [port]",
  640. #endif
  641. #ifdef TUTOR
  642.     "tutor",    dotutor,    512, 0, NULLCHAR,
  643. #endif
  644.     "udp",        doudp,        0, 0, NULLCHAR,
  645. #ifdef ALLCMD
  646.     "upload",   doupload,   0, 0, NULLCHAR,
  647. #endif
  648. /* This one is out of alpabetical order to allow abbreviation to "v" */
  649.     "view",        doview,        0, 2, "view <filename>",
  650. #ifdef ALLCMD
  651.     "version",     doversion,     0, 0, NULLCHAR,
  652. #endif
  653. #if defined(MSDOS) && defined(ALLCMD) && (SWATCH)
  654.     "watch",    doswatch,   0, 0, NULLCHAR,
  655. #endif
  656.     "watchdog", dowatchdog, 0, 0, NULLCHAR,
  657. #if defined(EXPIRY) && defined(WPAGES)
  658.     "wpages",dooldwpages, 0, 0, NULLCHAR,
  659. #endif
  660.     "write",    dowrite,    0, 3, "write <user|sock#> <msg>",
  661.     "writeall", dowriteall, 0, 2, "writeall <msg>",
  662. #ifdef XSPAWN
  663.     "xspawn",    doxspawn,   0, 0, NULLCHAR,
  664. #endif
  665. #ifdef MSDOS
  666. /* All commands from here to the end aren't displayed in help screen */
  667.     "a:",        dodrive,    0, 0, NULLCHAR,
  668.     "b:",        dodrive,    0, 0, NULLCHAR,
  669.     "c:",        dodrive,    0, 0, NULLCHAR,
  670.     "d:",        dodrive,    0, 0, NULLCHAR,
  671.     "e:",        dodrive,    0, 0, NULLCHAR,
  672.     "f:",        dodrive,    0, 0, NULLCHAR,
  673.     "g:",        dodrive,    0, 0, NULLCHAR,
  674. /* other drive can be added also.... */
  675. #endif
  676.     NULLCHAR,    NULLFP,        0, 0,
  677.         "Unknown command; type \"?\" for list",
  678. };
  679.  
  680. /* List of supported hardware devices */
  681. struct cmds Attab[] = {
  682. #ifdef    PC_EC
  683.     /* 3-Com Ethernet interface */
  684.     "3c500", ec_attach, 0, 7, 
  685.     "attach 3c500 <address> <vector> arpa <label> <buffers> <mtu> [ip_addr]",
  686. #endif
  687. #ifdef    ASY
  688.     /* Ordinary PC asynchronous adaptor */
  689.     "asy",    asy_attach, 0, 8, 
  690. #ifndef    AMIGA
  691. #ifdef    NRS
  692. #ifdef    PPP
  693.     "attach asy <address> <vector> slip|ax25|nrs|ppp <label> <buffers> <mtu> <speed> [options]",
  694. #else    /* PPP */
  695.     "attach asy <address> <vector> slip|ax25|nrs <label> <buffers> <mtu> <speed> [options]",
  696. #endif    /* PPP */
  697. #else    /* NRS */
  698. #ifdef    PPP
  699.     "attach asy <address> <vector> slip|ax25|ppp <label> <buffers> <mtu> <speed> [options]",
  700. #else    /* PPP */
  701.     "attach asy <address> <vector> slip|ax25 <label> <buffers> <mtu> <speed> [options]",
  702. #endif    /* PPP */
  703. #endif    /* NRS */
  704. #else
  705. #ifdef    NRS
  706. #ifdef    PPP
  707.      "attach asy <driver> <unit> slip|ax25|nrs|ppp <label> <buffers> <mtu> <speed> [options]",
  708. #else    /* PPP */
  709.      "attach asy <driver> <unit> slip|ax25|nrs <label> <buffers> <mtu> <speed> [options]",
  710. #endif    /* PPP */
  711. #else    /* NRS */
  712. #ifdef    PPP
  713.      "attach asy <driver> <unit> slip|ax25|ppp <label> <buffers> <mtu> <speed> [options]",
  714. #else    /* PPP */
  715.      "attach asy <driver> <unit> slip|ax25 <label> <buffers> <mtu> <speed> [options]",
  716. #endif    /* PPP */
  717. #endif    /* NRS */
  718. #endif    /* AMIGA */
  719. #endif    /* ASY */
  720. #ifdef    KISS
  721.     /* Multi-port KISS interface piggy-backing on ASY interface. */
  722.     "kiss", kiss_attach, 0, 4, 
  723.     "attach kiss <asy_interface_label> <port> <label> [mtu]",
  724. #endif    /* KISS */
  725. #ifdef    PC100
  726.     /* PACCOMM PC-100 8530 HDLC adaptor */
  727.     "pc100", pc_attach, 0, 8, 
  728.     "attach pc100 <address> <vector> ax25 <label> <buffers>\
  729.  <mtu> <speed> [ip_addra] [ip_addrb]",
  730. #endif
  731. #ifdef    DRSI
  732.     /* DRSI PCPA card in low speed mode */
  733.     "drsi", dr_attach, 0, 8,
  734.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu>\
  735. <chan a speed> <chan b speed> [ip addr a] [ip addr b]",
  736. #endif
  737. #ifdef    EAGLE
  738.     /* EAGLE RS-232C 8530 HDLC adaptor */
  739.     "eagle", eg_attach, 0, 8,
  740.     "attach eagle <address> <vector> ax25 <label> <buffers>\
  741.  <mtu> <speed> [ip_addra] [ip_addrb]",
  742. #endif
  743. #ifdef    HAPN
  744.     /* Hamilton Area Packet Radio (HAPN) 8273 HDLC adaptor */
  745.     "hapn", hapn_attach, 0, 8,
  746.     "attach hapn <address> <vector> ax25 <label> <rx bufsize>\
  747.  <mtu> csma|full [ip_addr]",
  748. #endif
  749. #ifdef    APPLETALK
  750.     /* Macintosh AppleTalk */
  751.     "0", at_attach, 0, 7,
  752.     "attach 0 <protocol type> <device> arpa <label> <rx bufsize> <mtu> [ip_addr]",
  753. #endif
  754. #ifdef NETROM
  755.     /* fake netrom interface */
  756.     "netrom", nr_attach, 0, 1,
  757.     "attach netrom [ip_addr]",
  758. #endif
  759. #ifdef    PACKET
  760.     /* FTP Software's packet driver spec */
  761.     "packet", pk_attach, 0, 4,
  762.     "attach packet <int#> <label> <buffers> <mtu> [ip_addr]",
  763. #endif
  764. #ifdef    HS
  765.     /* Special high speed driver for DRSI PCPA or Eagle cards */
  766.     "hs", hs_attach, 0, 7,
  767.     "attach hs <address> <vector> ax25 <label> <buffers> <mtu>\
  768.  <txdelay> <persistence> [ip_addra] [ip_addrb]",
  769. #endif
  770. #ifdef    PI
  771.     /* Special high speed driver for PI 8530 HDLC adapter */
  772.     "pi", pi_attach, 0, 8,
  773.     "attach pi <address> <vector> <dmachannel> ax25 <label> <buffers>\
  774.     <mtu> <speed a> <speed b> [ip_addra] [ip_addrb]",
  775. #endif
  776. #ifdef SCC
  777.     "scc", scc_attach, 0, 7,
  778.      "attach scc <devices> init <addr> <spacing> <Aoff> <Boff> <Dataoff>\n"
  779.     "   <intack> <vec> [p]<clock> [hdwe] [param]\n"
  780.     "attach scc <chan> slip|kiss|nrs|ax25 <label> <mtu> <speed> <bufsize> [call] ",
  781. #endif
  782. #ifdef AXIP
  783.     "axip",axip_attach, 0, 4,
  784.     "attach axip <name> <mtu> <remote-hostid> [callsign]",
  785. #endif
  786.     NULLCHAR,
  787. };
  788.  
  789. /* Functions to be called on each clock tick */
  790. void (*Cfunc[])() = {
  791.     pctick,    /* Call PC-specific stuff to keep time */
  792.     kbint,    /* Necessary because there's no hardware keyboard interrupt */
  793. #ifndef TNOS_68K
  794.     refiq,    /* Replenish interrupt pool */
  795. #endif
  796. #ifdef ITT
  797.     panictick,
  798.     gpstick,
  799. #endif
  800. #ifdef ASY
  801.     asytimer,
  802. #endif
  803. #ifdef    SCC
  804.     scctimer,
  805. #endif
  806.     NULL,
  807. };
  808.  
  809. #ifndef TNOS_68K
  810. /* Entry points for garbage collection */
  811. void (*Gcollect[])() = {
  812.     tcp_garbage,
  813.     ip_garbage,
  814.     udp_garbage,
  815.     st_garbage,
  816. #ifdef    AX25
  817.     lapb_garbage,
  818. #endif
  819. #ifdef    NETROM
  820.     nr_garbage,
  821. #endif
  822.     NULL
  823. };
  824. #endif
  825.  
  826. /* Functions to be called at shutdown */
  827. void (*Shutdown[])() = {
  828. #ifdef SCC
  829.     sccstop,
  830. #endif
  831. #ifndef TNOS_68K
  832.     uchtimer,    /* Unlink timer handler from timer chain */
  833. #endif
  834.     NULLVFP,
  835. };
  836.  
  837. /* Packet tracing stuff */
  838. #ifdef    TRACE
  839. #include "trace.h"
  840.  
  841. /* Protocol tracing function pointers. Matches list of class definitions
  842.  * in pktdrvr.h.
  843.  */
  844. struct trace DFAR Tracef[] = {
  845.     NULLFP,        ip_dump,    /* CL_NONE */
  846.  
  847. #ifdef    ETHER                /* CL_ETHERNET */
  848.     ether_forus,    ether_dump,
  849. #else
  850.     NULLFP,        NULLVFP,
  851. #endif    /* ETHER */
  852.  
  853.     NULLFP,        NULLVFP,    /* CL_PRONET_10 */
  854.     NULLFP,        NULLVFP,    /* CL_IEEE8025 */
  855.     NULLFP,        NULLVFP,    /* CL_OMNINET */
  856.  
  857. #ifdef    APPLETALK
  858.     at_forus,    at_dump,    /* CL_APPLETALK */
  859. #else
  860.     NULLFP,        NULLVFP,
  861. #endif    /* APPLETALK */
  862.  
  863. #ifdef VJCOMPRESS
  864.     NULLFP,        sl_dump,    /* CL_SERIAL_LINE */
  865. #else
  866.     NULLFP,        ip_dump,    /* CL_SERIAL_LINE */
  867. #endif
  868.     NULLFP,        NULLVFP,    /* CL_STARLAN */
  869.  
  870. #ifdef    ARCNET
  871.     arc_forus,    arc_dump,    /* CL_ARCNET */
  872. #else
  873.     NULLFP,        NULLVFP,
  874. #endif    /* ARCNET */
  875.  
  876. #ifdef    AX25
  877.     ax_forus,    ax25_dump,    /* CL_AX25 */
  878. #else
  879.     NULLFP,        NULLVFP,
  880. #endif    /* AX25 */
  881.  
  882. #ifdef    KISS                /* CL_KISS */
  883.     ki_forus,    ki_dump,
  884. #else
  885.     NULLFP,        NULLVFP,
  886. #endif    /* KISS */
  887.  
  888.     NULLFP,        NULLVFP,    /* CL_IEEE8023 */
  889.     NULLFP,        NULLVFP,    /* CL_FDDI */
  890.     NULLFP,        NULLVFP,    /* CL_INTERNET_X25 */
  891.     NULLFP,        NULLVFP,    /* CL_LANSTAR */
  892. #ifdef    SLFP
  893.     NULLFP,        ip_dump,    /* CL_SLFP */
  894. #else
  895.     NULLFP,        NULLVFP,
  896. #endif    /* SLFP */
  897.  
  898. #ifdef    NETROM                /* CL_NETROM */
  899.     NULLFP,        ip_dump,
  900. #else
  901.     NULLFP,        NULLVFP,
  902. #endif
  903.  
  904. #ifdef PPP
  905.     NULLFP,        ppp_dump,    /* CL_PPP */
  906. #else
  907.     NULLFP,        NULLVFP,
  908. #endif /* PPP */
  909. };
  910.  
  911. #else
  912.  
  913. /* Stub for packet dump function */
  914. void
  915. dump(iface,direction,type,bp)
  916. struct iface *iface;
  917. int direction;
  918. unsigned type;
  919. struct mbuf *bp;
  920. {
  921. }
  922. void
  923. raw_dump(iface,direction,bp)
  924. struct iface *iface;
  925. int direction;
  926. struct mbuf *bp;
  927. {
  928. }
  929.  
  930. #endif    /* TRACE */
  931.  
  932.  
  933. #ifdef    AX25
  934. #ifdef AUTOROUTE
  935. /* G4JEC's automatic ARP & Route resolution code primitive. */
  936. extern void ax25eavesdrop __ARGS((struct iface * iface,
  937.                             char *source, char * dest,
  938.                             struct mbuf * bp));
  939.  
  940. extern int Ax25_autoroute;
  941. #endif /* AUTOROUTE */
  942.  
  943. /* Hooks for passing incoming AX.25 data frames to network protocols */
  944. void
  945. axip(iface,axp,src,dest,bp,mcast)
  946. struct iface *iface;
  947. struct ax25_cb *axp;
  948. char *src;
  949. char *dest;
  950. struct mbuf *bp;
  951. int mcast;
  952. {
  953. #ifdef AUTOROUTE
  954.     struct mbuf *nbp;
  955.  
  956.     if(Ax25_autoroute) {
  957.         dup_p(&nbp, bp, 0, len_p(bp));
  958.         (void) ax25eavesdrop(iface,src,dest,nbp);
  959.         free_p(nbp);
  960.     }
  961. #endif
  962.     (void)ip_route(iface,bp,mcast);
  963. }
  964.  
  965. static void
  966. axarp(iface,axp,src,dest,bp,mcast)
  967. struct iface *iface;
  968. struct ax25_cb *axp;
  969. char *src;
  970. char *dest;
  971. struct mbuf *bp;
  972. int mcast;
  973. {
  974.     (void)arp_input(iface,bp);
  975. }
  976.  
  977. #ifdef RARP
  978. static void
  979. axrarp(iface,axp,src,dest,bp,mcast)
  980. struct iface *iface;
  981. struct ax25_cb *axp;
  982. char *src;
  983. char *dest;
  984. struct mbuf *bp;
  985. int mcast;
  986. {
  987.     (void)rarp_input(iface,bp);
  988. }
  989. #endif /* RARP */
  990.  
  991. #ifdef    NETROM
  992. static void
  993. axnr(iface,axp,src,dest,bp,mcast)
  994. struct iface *iface;
  995. struct ax25_cb *axp;
  996. char *src;
  997. char *dest;
  998. struct mbuf *bp;
  999. int mcast;
  1000. {
  1001.     if(!mcast)
  1002.         nr_route(bp,axp);
  1003.     else
  1004.         nr_nodercv(iface,src,bp);
  1005. }
  1006.  
  1007. #endif    /* NETROM */
  1008. #endif    /* AX25 */
  1009.  
  1010. #ifndef    RIP
  1011. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  1012. void
  1013. rt_timeout(s)
  1014. void *s;
  1015. {
  1016.     struct route *stale = (struct route *)s;
  1017.  
  1018.     rt_drop(stale->target,stale->bits);
  1019. }
  1020. #endif
  1021.  
  1022. #ifdef    SERVERS
  1023. /* "start" and "stop" subcommands */
  1024. static struct cmds DFAR Startcmds[] = {
  1025. #if    defined(AX25) && defined(MAILBOX)
  1026.     "ax25",        ax25start,    256, 0, NULLCHAR,
  1027. #endif
  1028. #if defined(CALLSERVER) || defined(SAMCALLB)
  1029.     "callbook",    cdbstart,    256, 0, NULLCHAR,
  1030. #endif
  1031. #ifdef  CONVERS
  1032.     "convers",    conv1,        384, 0, NULLCHAR,
  1033. #endif
  1034. #ifdef ALLSERV
  1035.     "daytime",    daytime1,    256, 0, NULLCHAR,
  1036.     "discard",  dis1,       256, 0, NULLCHAR,
  1037.     "echo",        echo1,        256, 0, NULLCHAR,
  1038. #endif
  1039.     "finger",   finstart,   256, 0, NULLCHAR,
  1040.     "ftp",        ftpstart,    256, 0, NULLCHAR,
  1041. #ifdef GPS
  1042.     "gps",        GPSstart,    256, 2, "start gps <interface>",
  1043. #endif
  1044. #ifdef TUTOR
  1045.     "info",        info1,        256, 0, NULLCHAR,
  1046. #endif
  1047. #if    defined(NETROM) && defined(MAILBOX)
  1048.     "netrom",    nr4start,    256, 0, NULLCHAR,
  1049. #endif
  1050. #ifdef TUTOR
  1051.     "news",        news1,        256, 0, NULLCHAR,
  1052. #endif
  1053. #ifdef    NNTPS
  1054.     "nntp",     nntp1,      256, 0, NULLCHAR,
  1055. #endif
  1056. #ifdef  POP
  1057.     "pop",        pop1,        256, 0, NULLCHAR,
  1058. #endif
  1059. #ifdef  POP2SERVER
  1060.     "pop2",         pop2start,      2048,0, NULLCHAR,
  1061. #endif
  1062. #ifdef    POP3SERVER
  1063.     "pop3",         pop3start,      2048,0, NULLCHAR,
  1064. #endif
  1065. #ifdef GPS
  1066.     "position",    POSstart,    256, 0, NULLCHAR,
  1067. #endif
  1068. #ifdef ALLSERV
  1069.     "quote",    quote1,        256, 0, NULLCHAR,
  1070. #endif
  1071.     "remote",   rem1,       768, 0, NULLCHAR,
  1072. #ifdef  RIP
  1073.     "rip",        doripinit,    0,   0, NULLCHAR,
  1074. #endif
  1075. #if defined(ALLSERV) && defined(RLOGINSERV)
  1076.     "rlogin",    rlogin1,    256, 0, NULLCHAR,
  1077. #endif
  1078.     "smtp",        smtp1,        512, 0, NULLCHAR,
  1079. #ifdef MAILBOX
  1080.     "telnet",    telnet1,    256, 0, NULLCHAR,
  1081. #ifdef ALLSERV
  1082.     "time",        time1,        256, 0, NULLCHAR,
  1083. #ifdef TIPMAIL
  1084.     "tip",      tipstart,   256, 2, "start tip <interface> [<modem|terminal>] [timeout seconds]",
  1085. #endif /* TIPMAIL */
  1086. #endif /* ALLSERV */
  1087. #endif /* MAILBOX */
  1088. #ifdef ALLSERV
  1089.     "ttylink",  ttylstart,  256, 0, NULLCHAR,
  1090. #endif
  1091. #ifdef TUTOR
  1092.     "tutor",    tutor1,     256, 0, NULLCHAR,
  1093. #endif
  1094.     NULLCHAR,
  1095. };
  1096. static struct cmds DFAR Stopcmds[] = {
  1097. #if    defined(AX25) && defined(MAILBOX)
  1098.     "ax25",        ax250,        0, 0, NULLCHAR,
  1099. #endif
  1100. #if defined(CALLSERVER) || defined(SAMCALLB)
  1101.     "callbook",    cdb0,        0, 0, NULLCHAR,
  1102. #endif
  1103. #ifdef  CONVERS
  1104.     "convers",  conv0,      384, 0, NULLCHAR,
  1105. #endif
  1106. #ifdef ALLSERV
  1107.     "daytime",    daytime0,    0, 0, NULLCHAR,
  1108.     "discard",  dis0,       0, 0, NULLCHAR,
  1109.     "echo",        echo0,        0, 0, NULLCHAR,
  1110. #endif
  1111.     "finger",   fin0,       0, 0, NULLCHAR,
  1112.     "ftp",        ftp0,        0, 0, NULLCHAR,
  1113. #ifdef GPS
  1114.     "gps",        GPSstop,    0, 2, "stop gps <interface>",
  1115. #endif
  1116. #ifdef TUTOR
  1117.     "info",        info0,        0, 0, NULLCHAR,
  1118. #endif
  1119. #if    defined(NETROM) && defined(MAILBOX)
  1120.     "netrom",    nr40,        0, 0, NULLCHAR,
  1121. #endif
  1122. #ifdef TUTOR
  1123.     "news",        news0,        0, 0, NULLCHAR,
  1124. #endif
  1125. #ifdef    NNTPS
  1126.     "nntp",     nntp0,      0, 0, NULLCHAR,
  1127. #endif
  1128. #ifdef  POP
  1129.     "pop",        pop0,        0, 0, NULLCHAR,
  1130. #endif
  1131. #ifdef  POP2SERVER
  1132.     "pop2",         pop2stop,      2048,0, NULLCHAR,
  1133. #endif
  1134. #ifdef    POP3SERVER
  1135.     "pop3",         pop3stop,      2048,0, NULLCHAR,
  1136. #endif
  1137. #ifdef GPS
  1138.     "position",    POSstop,    0, 0, NULLCHAR,
  1139. #endif
  1140. #ifdef ALLSERV
  1141.     "quote",    quote0,        0, 0, NULLCHAR,
  1142. #endif
  1143.     "remote",   rem0,       0, 0, NULLCHAR,
  1144. #ifdef  RIP
  1145.     "rip",        doripstop,    0, 0, NULLCHAR,
  1146. #endif
  1147. #if defined(ALLSERV) && defined(RLOGINSERV)
  1148.     "rlogin",    rlogin0,    0, 0, NULLCHAR,
  1149. #endif
  1150.     "smtp",        smtp0,        0, 0, NULLCHAR,
  1151. #ifdef    MAILBOX
  1152.     "telnet",    telnet0,    0, 0, NULLCHAR,
  1153. #ifdef ALLSERV
  1154.     "time",        time0,        0, 0, NULLCHAR,
  1155. #ifdef TIPMAIL
  1156.     "tip",      tip0,       0, 2, "stop tip <interface>",
  1157. #endif
  1158. #endif
  1159. #endif
  1160. #ifdef ALLSERV
  1161.     "ttylink",  ttyl0,      0, 0, NULLCHAR,
  1162. #endif
  1163. #ifdef TUTOR
  1164.     "tutor",    tutor0,     0, 0, NULLCHAR,
  1165. #endif
  1166.     NULLCHAR,
  1167.  
  1168. };
  1169. static int
  1170. dostart(argc,argv,p)
  1171. int argc;
  1172. char *argv[];
  1173. void *p;
  1174. {
  1175.     int insave,outsave;
  1176.  
  1177.     insave = Curproc->input;
  1178.     outsave = Curproc->output;
  1179.     Curproc->input = Cmdpp->input;
  1180.     Curproc->output = Cmdpp->output;
  1181.  
  1182.     subcmd(Startcmds,argc,argv,p);
  1183.  
  1184.     Curproc->input = insave;
  1185.     Curproc->output = outsave;
  1186.     return 0;
  1187. }
  1188.  
  1189. static int
  1190. dostop(argc,argv,p)
  1191. int argc;
  1192. char *argv[];
  1193. void *p;
  1194. {
  1195.     return subcmd(Stopcmds,argc,argv,p);
  1196. }
  1197. #endif    /* SERVERS */
  1198.  
  1199. /* Various configuration-dependent functions */
  1200.  
  1201. /* put mbuf into Hopper for network task
  1202.  * returns 0 if OK
  1203.  */
  1204. int
  1205. net_route(ifp, type, bp)
  1206. struct iface *ifp;
  1207. int type;
  1208. struct mbuf *bp;
  1209. {
  1210.     struct mbuf *nbp;
  1211.     struct phdr phdr;
  1212.  
  1213.     phdr.iface = ifp;
  1214.     phdr.type = type;
  1215.  
  1216.     if ((nbp = pushdown(bp,sizeof(phdr))) == NULLBUF ){
  1217.         return -1;
  1218.     }
  1219.     memcpy( &nbp->data[0],(char *)&phdr,sizeof(phdr));
  1220.     enqueue(&Hopper,nbp);
  1221.     /* Especially on slow machines, serial I/O can be quite
  1222.      * compute intensive, so release the machine before we
  1223.      * do the next packet.  This will allow this packet to
  1224.      * go on toward its ultimate destination. [Karn]
  1225.      */
  1226.     pwait(NULL);
  1227.     return 0;
  1228. }
  1229.  
  1230. /* Process packets in the Hopper */
  1231. static void
  1232. network(i,v1,v2)
  1233. int i;
  1234. void *v1;
  1235. void *v2;
  1236. {
  1237.     struct mbuf *bp;
  1238.     struct phdr phdr;
  1239.     int i_state;
  1240.  
  1241. loop:
  1242. #ifndef TNOS_68K
  1243.     refiq();    /* Replenish interrupt buffer pool */
  1244. #endif
  1245.  
  1246.     i_state = dirps();
  1247.     while(Hopper == NULLBUF)
  1248.         pwait(&Hopper);
  1249.     /* this is silly, first we turn ints on, then off again...? -WG7J */
  1250.     /* Process the input packet */
  1251.     /*    bp = dequeue(&Hopper);     */
  1252.  
  1253.     bp = Hopper;
  1254.     Hopper = Hopper->anext;
  1255.     bp->anext = NULLBUF;
  1256.  
  1257.     restore(i_state);
  1258.  
  1259.     pullup(&bp,(char *)&phdr,sizeof(phdr));
  1260.     if(phdr.iface != NULLIF){
  1261.         phdr.iface->rawrecvcnt++;
  1262.         phdr.iface->lastrecv = secclock();
  1263.     }
  1264. #ifdef TRACE
  1265.     dump(phdr.iface,IF_TRACE_IN,phdr.type,bp);
  1266. #endif
  1267.     switch(phdr.type){
  1268. #ifdef    KISS
  1269.     case CL_KISS:
  1270.         kiss_recv(phdr.iface,bp);
  1271.         break;
  1272. #endif
  1273. #ifdef    AX25
  1274.     case CL_AX25:
  1275.         ax_recv(phdr.iface,bp);
  1276.         break;
  1277. #endif
  1278. #ifdef    ETHER
  1279.     case CL_ETHERNET:
  1280.         eproc(phdr.iface,bp);
  1281.         break;
  1282. #endif
  1283. #ifdef ARCNET
  1284.     case CL_ARCNET:
  1285.         aproc(phdr.iface,bp);
  1286.         break;
  1287. #endif
  1288. #ifdef PPP
  1289.     case CL_PPP:
  1290.         ppp_proc(phdr.iface,bp);
  1291.         break;
  1292. #endif
  1293.     /* These types have no link layer protocol at the point when they're
  1294.      * put in the hopper, so they can be handed directly to IP. The
  1295.      * separate types are just for user convenience when running the
  1296.      * "iface" command.
  1297.      */
  1298.     case CL_NONE:
  1299.     case CL_SERIAL_LINE:
  1300.     case CL_SLFP:
  1301.         ip_route(phdr.iface,bp,0);
  1302.         break;
  1303.     default:
  1304.         free_p(bp);
  1305.         break;
  1306.     }
  1307.     /* Let everything else run - this keeps the system from wedging
  1308.      * when we're hit by a big burst of packets
  1309.      */
  1310.     pwait(NULL);
  1311.     goto loop;
  1312. }
  1313.